<template>
  <div class="container">
    <el-container>
      <el-header class="el_header">
        <div class="logo">
          <img src="@/assets/img/login_20.png" style="width:100%;height:100%;" alt="">
        </div>
        <div class="drop_menu">
          <img src="@/assets/img/userLogo.png" width="40">
          <el-dropdown>
            <span class="el-dropdown-link">
              {{Account}}<i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          </div>
      </el-header>
      <el-container class="main">
        <el-aside width="170px" style="background:rgb(84, 92, 100);">
          <el-menu background-color="#545c64" text-color="#ffffff" unique-opened>
            
            <el-submenu v-for="(item, index) in menus" :key="index" :index="String(index)">
              <template slot="title">{{item.Name}}</template>

              <template v-if="item.Children && item.Children.length>0">
                  <template v-for="(it, idx) in item.Children">
                     <nuxt-link :to="it.Path" :key="index+'-'+idx" ><el-menu-item :index="index+'-'+idx" v-if="it.Hidden == 0">{{it.Name}}</el-menu-item></nuxt-link>
                  </template>
              </template>
              
            </el-submenu>
            
          </el-menu>
        </el-aside>
        <el-main class="content">
          <div class="view">
            <nuxt-child />
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { getmenulist } from '@/assets/api'
export default {
  async asyncData({ store }) {
    let params = { Account:store.state.userInfo.Account, Token:store.state.token };
    const { Menus } = await getmenulist(params);
    return { Account:store.state.userInfo.Account, menus:Menus }
  },
  data(){
    return {
      
    }
  },
  mounted(){
    console.log(this.Account,this.menus);
  }
}
</script>
<style lang="scss" scoped>

.container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  .el_header{
    background: #ffffff;
    text-align: right;
    padding: 0;
    .logo{
      background: rgb(84, 92, 100);
      height: 60px;
      line-height: 60px;
      text-align: center;
      float: left;
      width: 170px;
      box-sizing: border-box;
      border-bottom: 1px solid #866363;
    }
    .drop_menu{
      display: inline-block;
      padding-top: 10px;
      box-sizing: border-box;
      margin-right: 40px;
      >img{
        vertical-align: middle;
      }
    }
    .el-dropdown-link {
      cursor: pointer;
    }
  }
  .main{
    position: absolute;
    top: 60px;
    bottom: 0;   
    display: flex;
    width: 100%;
    .content{
      flex: 1;
      .view{
        width: auto;
        min-width: 1200px;
      }
    }
  }
  .el-submenu{
    width: 170px;
    .el-menu-item{
      background: #170b0b59 !important;
      width: 170px;
      box-sizing: border-box;
      overflow: hidden;
      min-width:170px;
    }
  }
  
}
</style>

